package com.apexsoft.monitor.front.console.log.om;

import com.apexsoft.front.common.utils.SpringContextUtil;
import com.apexsoft.monitor.front.console.app.om.App;
import com.apexsoft.monitor.front.console.app.om.AppNode;
import com.apexsoft.monitor.front.console.app.service.AppNodeService;
import com.apexsoft.monitor.front.console.app.service.AppService;
import com.baomidou.mybatisplus.annotations.IdType;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;

@TableName("t_log")
public class Log {
	
	@TableId(type = IdType.AUTO)
	private Integer id;
	@TableField(value="app_code")
	private String appCode;
	@TableField(value="node_code")
	private String nodeCode;
	private String logFile;
	private String date;
	private String time;
	private String level;
	private String content;

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	public String getAppCode() {
		return appCode;
	}

	public void setAppCode(String appCode) {
		this.appCode = appCode;
	}

	public String getNodeCode() {
		return nodeCode;
	}

	public void setNodeCode(String nodeCode) {
		this.nodeCode = nodeCode;
	}

	public String getAppName(){
		AppService appService = (AppService) SpringContextUtil.getBean("appService");
		App app = appService.getByAppCode(this.getAppCode());
		return app==null?"data not found":app.getAppName();
	}
	public String getNodeName(){
		AppNodeService nodeService = (AppNodeService) SpringContextUtil.getBean("appNodeService");
		AppNode appNode = nodeService.getByCode(this.getNodeCode());
		return appNode==null?"data not found":appNode.getNodeName();
	}

	public String getLogFile() {
		return logFile;
	}

	public void setLogFile(String logFile) {
		this.logFile = logFile;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
}
